<?php
require_once __DIR__."/Base_model.php";
class Host_activity_activity_model extends Base_model
{
    public function __construct()
    {
        parent::__construct();
        $this->activity = "activity";
        $this->fenlei = "type";
        $this->huati = "type_sub";
        $this->template_photo = "template_photo";
        $this->wangchun_activity = "wangchun_activity";
    }
////////////////////////////////////////////////////////////////专题活动开始/////////////////////////////////////////////////////////////////////////////

    /**
     * 原始和弃用主页查询
     */
    public function all($arr){
        $this->db->select('*');
        $this->db->from($this->activity);
        //分页
        if(!empty($arr['page']) && !empty($arr['limit'])){
            $pages=($arr['page']-1)*$arr['limit'];
            $datas['total']=$this->db->count_all_results("",false);
            $this->db->limit($arr['limit'],$pages);
        }else{
            $datas['total']=$this->db->count_all_results("",false);
        }
//        $this->db->order_by('sort',"asc");
        $this->db->order_by('add_time',"desc");
        $res = $this->db->get();
        $datas['row']= $res->result_array();
//        echo $this->db->last_query();
        return $datas;
    }

    /**
     * 异步获取分类
     */
    public function get_fenlei($type=1){
        $this->db->select('*');
        $this->db->from($this->fenlei);
        if($type==1){
            $this->db->where("is_other !=",999999999);
            $this->db->where("online",2);
        }
        $res = $this->db->get();
        $datas= $res->result_array();
//        echo $this->db->last_query();
        return $datas;
    }

    /**
     * 异步获取分类
     */
    public function get_huati($huati_id="",$type=1){
        $this->db->select('*');
        $this->db->from($this->huati);
        if($type==1){
            $this->db->where("is_other !=",999999999);
            $this->db->where("online",2);
            $this->db->where("del2",2);
            $this->db->where("sub_type",$huati_id);
        }else if($type==2){
            $this->db->where("is_other !=",999999999);
            $this->db->where("online",2);
            $this->db->where("del2",2);
        }
        $res = $this->db->get();
        $datas= $res->result_array();
//        echo $this->db->last_query();
        return $datas;
    }

/////////////////////////////////////////////////////////////////专题活动结束//////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////网春大拜年开始///////////////////////////////////////////////////////////////////////////////////////

    /**
     * 原始和弃用主页查询
     */
    public function wangchun($arr){
        $this->db->select('*');
        $this->db->from($this->wangchun_activity);
        //分页
        if(!empty($arr['page']) && !empty($arr['limit'])){
            $pages=($arr['page']-1)*$arr['limit'];
            $datas['total']=$this->db->count_all_results("",false);
            $this->db->limit($arr['limit'],$pages);
        }else{
            $datas['total']=$this->db->count_all_results("",false);
        }
//        $this->db->order_by('sort',"asc");
        $this->db->order_by('add_time',"desc");
        $res = $this->db->get();
        $datas['row']= $res->result_array();
//        echo $this->db->last_query();
        return $datas;
    }

//////////////////////////////////////////////////////////////////网春大拜年结束///////////////////////////////////////////////////////////////////////////////////////
}